package com.ronx.scs.dao;

import com.ronx.scs.model.Registry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import javax.inject.Inject;
import java.util.List;

@Repository
public class RegistryDAO {

    @Autowired
    private HibernateTemplate template;

    public void add(Registry registry) {
        template.save(registry);
        template.flush();
    }

    public void update(Registry registry) {
        template.saveOrUpdate(registry);
        template.flush();
    }

    public void delete(Registry registry) {
        template.delete(registry);
        template.flush();
    }

    public List<Registry> getByNumber(String number) {
        return template.find("from Registry");
    }

    public List<Registry> getByOwner(String owner) {
        return template.find("from Registry");
    }
}
